package cn.wolfcode.trip.base.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * 积分变动表
 */
@Getter
@Setter
public class IntegralChange extends BaseDomain {
    //操作类型,0为增加,1为减少
    public static final int TYPE_SAVE = 0;
    public static final int TYPE_DECREASE = 1;
    //积分类型,0为登录,1为积分商城消费,2为积分抽奖
    public static final int INTEGRAL_SIGN = 0;
    public static final int INTEGRAL_STORE = 1;
    public static final int INTEGRAL_LUCK = 2;
    //积分数量
    public static final int BASIC_INTEGRAL = 5;
    //关联用户
    private User user;
    //操作类型
    private Integer changeType;
    //积分数量
    private Integer changeNum;
    //操作时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date changeTime;
    //积分变动类型
    private Integer integral;
    public String getIntegralDisplay(){
        String temp="";
        if(integral==INTEGRAL_SIGN){
            temp="登录";
        }else if(integral==INTEGRAL_STORE){
            temp="商城消费";
        }else if(integral==INTEGRAL_LUCK){
            temp="积分抽奖";
        }
        return temp;
    }
    /**
     *
     * 定义一个登录赠送积分的操作对象,方便操作
     * @return
     */
    public static IntegralChange getObject() {
        IntegralChange integralChange = new IntegralChange();
        integralChange.setChangeType(IntegralChange.TYPE_SAVE);
        integralChange.setIntegral(IntegralChange.INTEGRAL_SIGN);
        integralChange.setChangeNum(IntegralChange.BASIC_INTEGRAL);
        return integralChange;
    }
}